package com.wjh.controller;

import com.wjh.entities.CommonResult;
import com.wjh.entities.Payment;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;

@RestController
public class PaymentController {

    @Value("${server.port}")
    private String port;

    public static HashMap<Long, Payment> hashMap = new HashMap<>();
    static {
        hashMap.put(1L, new Payment(1l, "asdrfd423rdsvsdgearg6546erfgxdg4"));
        hashMap.put(2L, new Payment(2l, "asdrfsdffd423rdsvsrg6546erfgxhf3"));
        hashMap.put(3L, new Payment(3l, "ascefd423rdsxadgvafg6546erfwqer2"));
    }

    @GetMapping("/paymentSQL/{id}")
    public CommonResult<Payment> paymentSQL(@PathVariable("id") Long id){
        Payment payment = hashMap.get(id);
        CommonResult result = new CommonResult(200, "from mysql, serverPort:" + port, payment);
        return result;
    }
}